package it.controllocredito.frontend.activities;

import it.controllocredito.R;
import it.controllocredito.backend.services.LocalService;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener {

	private static final String activity_name = "MainActivity";
	Button buttonStart, buttonStop;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		buttonStart = (Button) findViewById(R.id.buttonStart);
		buttonStop = (Button) findViewById(R.id.buttonStop);
	
		buttonStart.setOnClickListener(this);
		buttonStop.setOnClickListener(this);
	}

	public void onClick(View src) {
		switch (src.getId()) {
			case R.id.buttonStart:
				Log.d(activity_name, "onClick: starting service");
				startService(new Intent(this, LocalService.class));
				break;
			case R.id.buttonStop:
				Log.d(activity_name, "onClick: stopping service");
				stopService(new Intent(this, LocalService.class));
				break;
		}
	}

}